home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / HashTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  2.8 KB  |  108 lines

  1. #ifndef __HASHTABLE_H__
  2. #define __HASHTABLE_H__
  3.  
  4. /*
  5.  *   $RCSfile: HashTable.h,v $  
  6.  *   $Revision: 1.1.1.1 $  
  7.  *   $Date: 1996/05/04 21:55:07 $      
  8.  */ 
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40. #ifndef __cplusplus
  41.     This file MUST be compiled with C++ !
  42. #endif
  43.  
  44.  
  45. #include "sysdefs.h"
  46. #include "ess.h"
  47. #include "checking.h"
  48. #include "list.h"
  49. #include "trace.h"
  50. #include "error.h"
  51. #include "ForEach.h"
  52.  
  53.  
  54. template <class HASHTKEY,class CONTENTS>
  55. class HashTable {
  56. private:
  57.  
  58.     LIST        *buckets;
  59.     int            numBuckets;    /* # slots */
  60. #ifdef DEBUG
  61.     FOREACHFUNC    dumpFunc;
  62. #endif DEBUG
  63.  
  64.     int            numEmptyBuckets;
  65.     int            bucketSizeHighWater; 
  66.     unsigned int    mask;
  67.     char        name[32];
  68.     int            unique; /* id of resource */
  69.     int            spaceRequirement; /* in number of bytes */
  70.  
  71.     /* 
  72.      * These member funcs have to be defined for the HASHTKEY class:
  73.      * int hashFunc();
  74.      * BOOL equalFunc( HASHTKEY *);
  75.      * These member funcs have to be defined for the CONTENTS class:
  76.      * Dump(FILE *)
  77.      * LISTELEMENT *listlocation(int);
  78.      * HASHTKEY *keylocation(int);
  79.     */
  80. public:
  81.     int            numItems;     /* in the table */
  82.     HashTable( char *, int, int );
  83.     ~HashTable() ;
  84.     CONTENTS     *Find ( const HASHTKEY *) ; 
  85.     void    Insert( CONTENTS     *) ;
  86.     void    Remove( CONTENTS *) ;
  87.  
  88. #ifndef __GNUC__
  89.     void    ForEach(  int,    FOREACHFUNC, ... ) ;
  90. #else
  91.     void    ForEach(  int,    ... ) ;
  92. #endif
  93.  
  94.     void    Stats( FILE * );
  95.     char     *Name() { return &name[0]; };
  96. #ifdef DEBUG
  97.     void    Dump( FILE *,  int, char *);
  98. #endif DEBUG
  99. };
  100.  
  101. #ifdef  __GNUC__
  102. #include "HashTable.c"
  103. #endif  __GNUC__
  104.  
  105. #endif __HASHTABLE_H__
  106.  
  107.  
  108.